package com.example.huainanlive

import com.demon.net.RetrofitFactory
import com.demon.net.factory.CouroutineRetrofitFactory
import com.demon.net.factory.IRetrofitFactory.RetrofitConfig
import com.example.huainanlive.server.CommonParamInterceptor
import com.example.huainanlive.server.LoginParamInterceptor
import com.example.huainanlive.factory.CouroutineRetrofitSecondFactory
import com.example.huainanlive.factory.s.CouroutineRetrofitThridFactory

/**
 * 类简要描述
 * <p/>
 * <p>
 * 类详细描述
 * </p>
 *
 * @author zhaozeyang
 * @date 1/20/21
 */
object ApiClient {
    //TODO 暂都使用测试接口
    //api/app/livehouse/getLiveHousePreview


    val URL =  "http://112.30.213.205:8082/"
    //val URL = "https://rockysports.cn/"
    private val config = RetrofitConfig(URL, interceptors = listOf(CommonParamInterceptor()))
    private val loginConfig = RetrofitConfig(URL, interceptors = listOf(LoginParamInterceptor()))
    private val factory = CouroutineRetrofitFactory(config)
    private val factorySecond = CouroutineRetrofitSecondFactory(config)
    private val factoryThrid = CouroutineRetrofitThridFactory(config)

    fun <T> createService(clazz: Class<T>): T = factory.createService(clazz)
    fun <T> createServiceSecond(clazz: Class<T>): T = factorySecond.createService(clazz)
    fun <T> createServiceThrid(clazz: Class<T>): T = factoryThrid.createService(clazz)

    fun <T> createRxService(clazz: Class<T>): T = RetrofitFactory.createService(clazz, URL, CommonParamInterceptor())

    private val loginFactory = CouroutineRetrofitFactory(loginConfig)
    fun <T> createAuthService(clazz: Class<T>): T = loginFactory.createService(clazz)
}